package com.yn.iotxiao.controller.Device;

import com.yn.iotxiao.Utils.JsonHelper;
import com.yn.iotxiao.request.PageRequest;
import com.yn.iotxiao.response.ResponseResult;
import com.yn.iotxiao.sql.services.Record.PassRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/record")
@Slf4j
@RestController
@ResponseResult
public class RecordController {

    @Autowired
    PassRecordService recordService;
    @PostMapping("/pass")
    public Object getPassRecord(@RequestBody PageRequest request) {

        var list = recordService.getListPage(request.getSearchKey(),request.getPage(),request.getPageSize());
        var total = recordService.getTotal(request.getSearchKey());

        return JsonHelper.create("total",total,"list",list);
    }
}
